﻿using System;
using LayuiBlazor.Components;
using LayuiBlazor.Localization.Json;
using LayuiBlazor.Options;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace LayuiBlazor.Extensions
{
    public static class LayuiBlazorServiceCollectionExtensions
    {
        public static IServiceCollection AddLayuiBlazor(this IServiceCollection services, Action<LayuiBlazorOptions>? configureOptions = null, Action<JsonLocalizationOptions>? setupAction = null)
        {
            services.AddAuthorizationCore();
            services.AddJsonLocalization(setupAction);
            services.TryAddScoped<IComponentIdGenerator, DefaultIdGenerator>();
            services.AddOptions();
            services.Configure(configureOptions);
            ServiceProviderHelper.RegisterService(services);
            return services;
        }
    }
}
